package com.book.common;

import java.util.HashMap;
import java.util.Map;

/**
 * @version 1.0
 * @Author Jincheng.Li
 * @Date 2021/5/20 7:53 下午
 * @Project_Name graduation-project
 */
public enum RedisUserCacheEnum {
    REDIS_USER_CACHE_PHONE(1,"user_phone"),
    REDIS_USER_CACHE_NAME(2,"user_name"),
    REDIS_USER_CACHE_EMAIL(3,"user_email");

    private  int id;
    private  String value;
    RedisUserCacheEnum (int id, String value){
        this.id = id;
        this.value = value;
    }
    private static Map<Integer, RedisUserCacheEnum > asEnumMaps = new HashMap<>();
    public static Map<Integer,String> maps = new HashMap<>();
    public static Map<String,Integer> valueMaps = new HashMap<>();
    static {
        for(RedisUserCacheEnum  asEnum : RedisUserCacheEnum .values()) {
            asEnumMaps.put(asEnum.getId(), asEnum);
            maps.put(asEnum.getId(),asEnum.getValue());
            valueMaps.put(asEnum.getValue(),asEnum.getId());
        }
    }
    public static String get(int id) {
        return asEnumMaps.get(id).getValue();
    }

    public String getValue() {
        return value;
    }

    public int getId() {
        return id;
    }

    public static Integer getId(String msg){
        return valueMaps.get(msg);
    }
}
